package com.xiaoyu.izf.model;


import cn.hutool.core.date.DateUtil;

import javax.persistence.*;
import java.sql.Timestamp;
import java.util.Objects;

@Entity
@Table(name = "news_info", schema = "izf", catalog = "")
public class NewsInfo {
    private int id;
    private String img;
    private Timestamp addTime;
    private String description;
    private String title;
    private Integer click;
    private String editor;
    private String thumb;
    private Integer hot;
    private String detail;
    private Integer cid;
    private Integer isDel;


    private String newsUrl;
    private String addTimeStr;

    @Id
    @Column(name = "id")
    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    @Basic
    @Column(name = "img")
    public String getImg() {
        return img;
    }

    public void setImg(String img) {
        this.img = img;
    }

    @Basic
    @Column(name = "add_time")
    public Timestamp getAddTime() {
        return addTime;
    }

    public void setAddTime(Timestamp addTime) {
        this.addTime = addTime;
    }

    @Basic
    @Column(name = "description")
    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    @Basic
    @Column(name = "title")
    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    @Basic
    @Column(name = "click")
    public Integer getClick() {
        return click;
    }

    public void setClick(Integer click) {
        this.click = click;
    }

    @Basic
    @Column(name = "editor")
    public String getEditor() {
        return editor;
    }

    public void setEditor(String editor) {
        this.editor = editor;
    }

    @Basic
    @Column(name = "thumb")
    public String getThumb() {
        return thumb;
    }

    public void setThumb(String thumb) {
        this.thumb = thumb;
    }

    @Basic
    @Column(name = "hot")
    public Integer getHot() {
        return hot;
    }

    public void setHot(Integer hot) {
        this.hot = hot;
    }

    @Basic
    @Column(name = "detail")
    public String getDetail() {
        return detail;
    }

    public void setDetail(String detail) {
        this.detail = detail;
    }

    @Basic
    @Column(name = "cid")
    public Integer getCid() {
        return cid;
    }

    public void setCid(Integer cid) {
        this.cid = cid;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        NewsInfo newsInfo = (NewsInfo) o;
        return id == newsInfo.id &&
                Objects.equals(img, newsInfo.img) &&
                Objects.equals(addTime, newsInfo.addTime) &&
                Objects.equals(description, newsInfo.description) &&
                Objects.equals(title, newsInfo.title) &&
                Objects.equals(click, newsInfo.click) &&
                Objects.equals(editor, newsInfo.editor) &&
                Objects.equals(thumb, newsInfo.thumb) &&
                Objects.equals(hot, newsInfo.hot) &&
                Objects.equals(detail, newsInfo.detail) &&
                Objects.equals(cid, newsInfo.cid);
    }

    @Override
    public int hashCode() {
        return Objects.hash(id, img, addTime, description, title, click, editor, thumb, hot, detail, cid);
    }

    @Basic
    @Column(name = "is_del")
    public Integer getIsDel() {
        return isDel;
    }

    public void setIsDel(Integer isDel) {
        this.isDel = isDel;
    }

    @Basic
    @Column(name = "news_url")
    public String getNewsUrl() {
        return newsUrl;
    }

    public void setNewsUrl(String newsUrl) {
        this.newsUrl = newsUrl;
    }

    @Transient
    public String getAddTimeStr() {
        return DateUtil.date(addTime.getTime()).toString();
    }
}
